package cc.catface.base.db;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

import cc.catface.base.db.dao.UserDao;
import cc.catface.base.db.table.User;
import cc.catface.commom.context.TApp;

/** 数据库:ROOM */
@Database(entities = {User.class}, version = 1, exportSchema = false)
public abstract class DBHelper extends RoomDatabase {

    private static final String DB_FILE_PATH = "db_catface.db";

    public static synchronized DBHelper getInstance() {
        return Holder.instance;
    }

    private static class Holder {
        private static final DBHelper instance = Room.databaseBuilder(TApp.getInstance(), DBHelper.class, DB_FILE_PATH)
                //.allowMainThreadQueries()//允许在主线程中执行操作(影响流畅性)
                .build();
    }

    public abstract UserDao getUserDao();
}